package collection.listUse;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author Devin
 * @program my-java
 * @description
 * @date 2024-04-08 10:16
 **/
public class Test1 {
    public static void main(String[] args) {
        binarySearch();
    }

    public static void binarySearch() {
        List<Integer> sequence = new ArrayList<>();
        sequence.add(1);
        sequence.add(3);
        sequence.add(5);
        sequence.add(6);
        sequence.add(19);

        int target = 19;
        int index = Collections.binarySearch(sequence, target);

        if (index >= 0 && index < sequence.size() - 1) {
            int next = sequence.get(index + 1);
            System.out.println("给定数的后一个数是：" + next);
        } else {
            System.out.println("没有找到后一个数");
        }
    }
}
